package core;

import java.awt.Dimension;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

import javax.swing.ImageIcon;

import projectiles.Projectile;

/**
 * @author Victor Jimenez Kwast
 * @version 1.1
 * @since 2011-04-11
 */
public abstract class ShootingUnit extends Unit {

	protected Ellipse2D.Double rangeBounds;
	protected int firerate;
	protected int range;
	protected long nextFire;

	/**
	 * 
	 * @param position de positie van de unit
	 * @param health de hitpoitns van de unit
	 * @param image het plaatje
	 * @param size de groote van het plaatje
	 * @param viewAngle welke kant de unit op kijkt
	 * @param range de afstand waarover hij kan schieten
	 * @param firerate de snelheid waarop de unit schiet
	 */
	/* /// Constructor //////////////////////////////////////// */
	public ShootingUnit(Point2D.Double position, int health, ImageIcon image, Dimension size, int viewAngle, int range,
			int firerate) {
		super(position, health, image, size, viewAngle);

		this.firerate = firerate;
		this.range = range;

		this.nextFire = System.currentTimeMillis() + firerate;
	}

	/* /// getFirerate //////////////////////////////////////// */
	public int getFirerate() {
		return firerate;
	}

	/**
	 * Tijd (in de toekomst) wanneer unit weer mag schieten
	 */
	/* /// updateFirerate //////////////////////////////////////// */
	public void updateFirerate() {
		nextFire = System.currentTimeMillis() + firerate;
	}

	/* /// getRange //////////////////////////////////////// */
	public int getRange() {
		return range;
	}

	/* /// canShoot //////////////////////////////////////// */
	public boolean canShoot() {
		return (nextFire <= System.currentTimeMillis());
	}

	/**
	 * @see core.Unit#draw(java.awt.Graphics, java.awt.Rectangle, java.awt.Component)
	 */
	/* /// Projectile shoot //////////////////////////////////////// */
	public abstract Projectile shoot();



}
